<?php
    $name = pc_variable("name");
    $entities = pc_variable("entities");
    $ids = pc_variable("ids");
    $typeName = pc_variable("typeName");
    $typeConfig = pc_config("cm.type." . $typeName);
    $primaryPropertyName = $typeConfig->getPrimaryPropertyName();
    if($entities->isEmpty()) { ?><li>
        (<?php pc_echo(pc_message("showEntity.empty", array(Pageley_Util_String::uncapitalize(pc_message("namespace." . $typeName . ".plural"))))); ?>)
    </li><?php }
    foreach($entities as $entity) { ?>
        <li>
            <input type="checkbox" name="entity.<?php pc_echo($name); ?>[]" id="entity.<?php pc_echo($name . "[" . $entity->getId() . "]"); ?>" value="<?php pc_echo($entity->getId()); ?>"<?php if($ids !== null && $ids->containsValue($entity->getId())) {?> checked="checked"<?php } ?>/>
            <label class="check" for="entity.<?php pc_echo($name . "[" . $entity->getId() . "]"); ?>"><?php pc_echo($entity->get($primaryPropertyName)); ?></label>
        </li>
<?php } ?>